<?xml version="1.0" encoding="UTF-8"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!--
    POM file.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>

    <parent>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-parent-internal</artifactId>
        <version>${revision}</version>
        <relativePath>../../../parent-internal/pom.xml</relativePath>
    </parent>

    <artifactId>ignite-extdata-uri</artifactId>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ignite-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ignite-extdata-uri-dep</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <modules>
        <module>modules/uri-dependency</module>
    </modules>

    <properties>

        <uri.fn>uri</uri.fn>
        <uri.jar>${uri.fn}.jar</uri.jar>

        <plain.fn>deployfile</plain.fn>
        <plain.clr>plain</plain.clr>
        <plain.jar>${plain.fn}-${plain.clr}.jar</plain.jar>

        <well-signed.fn>deployfile</well-signed.fn>
        <well-signed.clr>well-signed</well-signed.clr>
        <well-signed.jar>${well-signed.fn}-${well-signed.clr}.jar</well-signed.jar>

        <bad-signed.fn>deployfile</bad-signed.fn>
        <bad-signed.clr>bad-signed</bad-signed.clr>
        <bad-signed.jar>${bad-signed.fn}-${bad-signed.clr}.jar</bad-signed.jar>

    </properties>

    <build>

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>deploy</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <!-- need to compile sources. pom packaging will not compile automatically. -->
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jar-uri</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>${uri.fn}</finalName>
                            <outputDirectory>${basedir}/target/deploy</outputDirectory>
                            <includes>
                                <include>**/GridUriDeploymentTestTask8.class</include>
                                <include>**/GridUriDeploymentTestWithNameTask8.class</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jar-plain</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>${plain.fn}</finalName>
                            <classifier>${plain.clr}</classifier>
                            <outputDirectory>${basedir}/target/file</outputDirectory>
                            <includes>
                                <include>**/GridUriDeploymentTestTask8.class</include>
                                <include>**/GridUriDeploymentTestWithNameTask8.class</include>
                                <include>**/GridUriDeploymentTestTask9.class</include>
                                <include>**/GridUriDeploymentDependency9.class</include>
                                <include>**/test9.properties</include>
                                <include>**/spring9.xml</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jar-well-signed</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>${well-signed.fn}</finalName>
                            <classifier>${well-signed.clr}</classifier>
                            <outputDirectory>${basedir}/target/file</outputDirectory>
                            <includes>
                                <include>**/GridUriDeploymentTestTask10.class</include>
                                <include>**/GridUriDeploymentTestWithNameTask10.class</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jar-bad-signed</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>${bad-signed.fn}</finalName>
                            <classifier>${bad-signed.clr}</classifier>
                            <outputDirectory>${basedir}/target/file</outputDirectory>
                            <includes>
                                <include>**/GridUriDeploymentTestTask11.class</include>
                                <include>**/GridUriDeploymentTestWithNameTask11.class</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>sign-well</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <archive>${basedir}/target/file/${well-signed.jar}</archive>
                            <keystore>${basedir}/config/signeddeploy/keystore</keystore>
                            <alias>business</alias>
                            <storepass>abc123</storepass>
                            <keypass>abc123</keypass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.mail</groupId>
                        <artifactId>javax.mail</artifactId>
                        <version>1.5.2</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>jar-badly-signed</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask11.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask11.class" tofile="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class" />

                                <jar destfile="${basedir}/target/file/${bad-signed.jar}" basedir="${basedir}/target/file_tmp/classes" />

                                <signjar jar="${basedir}/target/file/${bad-signed.jar}" keystore="${basedir}/config/signeddeploy/keystore" storepass="abc123" keypass="abc123" alias="business" />

                                <sleep seconds="2" />

                                <touch file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class" />

                                <zip destfile="${basedir}/target/file/${bad-signed.jar}" basedir="${basedir}/target/classes/" includes="org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class" update="yes" />

                                <delete dir="${basedir}/target/file_tmp/"/>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>gar</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <taskdef name="gar" classname="org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask" />

                                <!-- copying resources to classes -->
                                <copy todir="${basedir}/target/classes">
                                    <fileset dir="${basedir}/src/main/java">
                                        <include name="**/*.xml" />
                                        <include name="**/*.properties" />
                                    </fileset>
                                </copy>

                                <mkdir dir="${basedir}/target/deploy_tmp/" />

                                <!--uri-classes.gar-->
                                <gar destfile="${basedir}/target/deploy2/uri-classes.gar" basedir="${basedir}/target/classes" />

                                <!--Copy libs-->
                                <zip destfile="${basedir}/target/classes/lib/depend.jar" encoding="UTF-8">
                                    <zipfileset dir="modules/uri-dependency/target/classes" />
                                </zip>

                                <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" />

                                <!--uri-libs.gar-->
                                <gar destfile="${basedir}/target/deploy2/uri-libs.gar" basedir="${basedir}/target/classes/lib" />

                                <!--uri.gar-->
                                <gar destfile="${basedir}/target/deploy/uri.gar" basedir="${basedir}/target/classes" />

                                <!--
                                This is created for test GridTaskUriDeploymentDeadlockSelfTest.
                                We put two files here to have a collision and make deployment SPI to unregister class loaders.
                                This is intended to test GG-2852 issue.
                                -->
                                <gar destfile="${basedir}/target/resources/helloworld.gar" descrdir="${basedir}/META-INF" basedir="${basedir}/target/classes" />
                                <gar destfile="${basedir}/target/resources/helloworld1.gar" descrdir="${basedir}/META-INF" basedir="${basedir}/target/classes" />

                                <!--deploydir.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/deploydir-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask0.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask0.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deploydir0.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />
                                <mkdir dir="${basedir}/target/file/deploydir.gar" />
                                <unzip src="${basedir}/target/file/deploydir0.gar" dest="${basedir}/target/file/deploydir.gar" />
                                <delete file="${basedir}/target/file/deploydir0.gar" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--deployfile.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/deployfile-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask3.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask3.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deployfile.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--deployfile-nodescr.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask4.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask4.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deployfile-nodescr.gar" basedir="${basedir}/target/file_tmp/classes" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--deployfile-bad.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/bad-classes-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentAbstractTestTask.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentInnerTestTask.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentInnerTestTask$GridInnerTestTask.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentInterfaceTestTask.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentNonePublicTestTask.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deployfile-bad.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--deployfile-depend.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/deploydepend-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask1.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentDependency1.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/test1.properties" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deployfile-depend.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />
                                <zip destfile="${basedir}/target/file/deployfile-depend.gar" basedir="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/" includes="spring1.xml" update="yes" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--deploydir-nodescr-depend.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask2.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentDependency2.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/test2.properties" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/spring2.xml" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/deploydir-nodescr-depend0.gar" basedir="${basedir}/target/file_tmp/classes" />
                                <mkdir dir="${basedir}/target/file/deploydir-nodescr-depend.gar" />
                                <unzip src="${basedir}/target/file/deploydir-nodescr-depend0.gar" dest="${basedir}/target/file/deploydir-nodescr-depend.gar" />
                                <delete file="${basedir}/target/file/deploydir-nodescr-depend0.gar" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--well-signed-deployfile.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/well-signed-deployfile-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask5.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask5.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />

                                <gar destfile="${basedir}/target/file/well-signed-deployfile.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />

                                <signjar jar="${basedir}/target/file/well-signed-deployfile.gar" keystore="${basedir}/config/signeddeploy/keystore" storepass="abc123" keypass="abc123" alias="business" />

                                <delete dir="${basedir}/target/file_tmp/" />

                                <!--bad-signed-deployfile.gar-->
                                <mkdir dir="${basedir}/target/file_tmp/META-INF/" />
                                <copy file="${basedir}/META-INF/bad-signed-deployfile-ignite.xml" tofile="${basedir}/target/file_tmp/META-INF/ignite.xml" />

                                <mkdir dir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask6.class" todir="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/" />
                                <copy file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestTask6.class" tofile="${basedir}/target/file_tmp/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask6.class" />

                                <gar destfile="${basedir}/target/file/bad-signed-deployfile.gar" descrdir="${basedir}/target/file_tmp/META-INF" basedir="${basedir}/target/file_tmp/classes" />

                                <signjar jar="${basedir}/target/file/bad-signed-deployfile.gar" keystore="${basedir}/config/signeddeploy/keystore" storepass="abc123" keypass="abc123" alias="business" />

                                <sleep seconds="2" />

                                <touch file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask6.class" />

                                <zip destfile="${basedir}/target/file/bad-signed-deployfile.gar" basedir="${basedir}/target/classes/" includes="org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask6.class" update="yes" />

                                <delete dir="${basedir}/target/file_tmp/" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
